import sys
from mido import MetaMessage, MidiFile, MidiTrack, Message

chords = {
    # 大三和弦
    'C': [60, 64, 67],     # C大三和弦: C4, E4, G4
    'D': [62, 66, 69],     # D大三和弦: D4, F#4, A4
    'E': [64, 68, 71],     # E大三和弦: E4, G#4, B4
    'F': [65, 69, 72],     # F大三和弦: F4, A4, C5
    'G': [67, 71, 74],     # G大三和弦: G4, B4, D5
    'A': [69, 73, 76],     # A大三和弦: A4, C#5, E5
    'B': [71, 75, 79],     # B大三和弦: B4, D#5, F#5

    # 小三和弦
    'Cm': [60, 63, 67],    # C小三和弦: C4, Eb4, G4
    'Dm': [62, 65, 69],    # D小三和弦: D4, F4, A4
    'Em': [64, 67, 71],    # E小三和弦: E4, G4, B4
    'Fm': [65, 68, 72],    # F小三和弦: F4, Ab4, C5
    'Gm': [67, 70, 74],    # G小三和弦: G4, Bb4, D5
    'Am': [69, 72, 76],    # A小三和弦: A4, C5, E5
    'Bm': [71, 74, 79],    # B小三和弦: B4, D5, F#5

    # 大七和弦
    'Cmaj7': [60, 64, 67, 71],  # C大七和弦: C4, E4, G4, B4
    'Dmaj7': [62, 66, 69, 73],  # D大七和弦: D4, F#4, A4, C#5
    'Emaj7': [64, 68, 71, 75],  # E大七和弦: E4, G#4, B4, D#5
    'Fmaj7': [65, 69, 72, 76],  # F大七和弦: F4, A4, C5, E5
    'Gmaj7': [67, 71, 74, 78],  # G大七和弦: G4, B4, D5, F#5
    'Amaj7': [69, 73, 76, 80],  # A大七和弦: A4, C#5, E5, G#5
    'Bmaj7': [71, 75, 79, 83],  # B大七和弦: B4, D#5, F#5, A#5

    # 小七和弦
    'Cm7': [60, 63, 67, 70],   # C小七和弦: C4, Eb4, G4, Bb4
    'Dm7': [62, 65, 69, 72],   # D小七和弦: D4, F4, A4, C5
    'Em7': [64, 67, 71, 74],   # E小七和弦: E4, G4, B4, D5
    'Fm7': [65, 68, 72, 75],   # F小七和弦: F4, Ab4, C5, Eb5
    'Gm7': [67, 70, 74, 77],   # G小七和弦: G4, Bb4, D5, F5
    'Am7': [69, 72, 76, 79],   # A小七和弦: A4, C5, E5, G5
    'Bm7': [71, 74, 79, 82],   # B小七和弦: B4, D5, F#5, A5

    # 属七和弦
    'C7': [60, 64, 67, 70],    # C7和弦: C4, E4, G4, Bb4
    'D7': [62, 66, 69, 72],    # D7和弦: D4, F#4, A4, C5
    'E7': [64, 68, 71, 74],    # E7和弦: E4, G#4, B4, D5
    'F7': [65, 69, 72, 75],    # F7和弦: F4, A4, C5, Eb5
    'G7': [67, 71, 74, 77],    # G7和弦: G4, B4, D5, F5
    'A7': [69, 73, 76, 79],    # A7和弦: A4, C#5, E5, G5
    'B7': [71, 75, 79, 82],    # B7和弦: B4, D#5, F#5, A5

    # 大九和弦
    'Cmaj9': [60, 64, 67, 71, 74],   # C大九和弦: C4, E4, G4, B4, D5
    'Dmaj9': [62, 66, 69, 73, 76],   # D大九和弦: D4, F#4, A4, C#5, E5
    'Emaj9': [64, 68, 71, 75, 78],   # E大九和弦: E4, G#4, B4, D#5, F#5
    'Fmaj9': [65, 69, 72, 76, 79],   # F大九和弦: F4, A4, C5, E5, G5
    'Gmaj9': [67, 71, 74, 78, 81],   # G大九和弦: G4, B4, D5, F#5, A5
    'Amaj9': [69, 73, 76, 80, 83],   # A大九和弦: A4, C#5, E5, G#5, B5
    'Bmaj9': [71, 75, 79, 83, 86],   # B大九和弦: B4, D#5, F#5, A#5, C#6

    # 小九和弦
    'Cm9': [60, 63, 67, 70, 74],   # C小九和弦: C4, Eb4, G4, Bb4, D5
    'Dm9': [62, 65, 69, 72, 75],   # D小九和弦: D4, F4, A4, C5, E5
    'Em9': [64, 67, 71, 74, 78],   # E小九和弦: E4, G4, B4, D5, F#5
    'Fm9': [65, 68, 72, 75, 79],   # F小九和弦: F4, Ab4, C5, Eb5, G5
    'Gm9': [67, 70, 74, 77, 81],   # G小九和弦: G4, Bb4, D5, F5, A5
    'Am9': [69, 72, 76, 79, 83],   # A小九和弦: A4, C5, E5, G5, B5
    'Bm9': [71, 74, 79, 82, 86],   # B小九和弦: B4, D5, F#5, A5, C#6

    # 增和弦
    'Caug': [60, 64, 68],   # C增和弦: C4, E4, G#4
    'Daug': [62, 66, 70],   # D增和弦: D4, F#4, A#4
    'Eaug': [64, 68, 72],   # E增和弦: E4, G#4, C5
    'Faug': [65, 69, 73],   # F增和弦: F4, A4, C#5
    'Gaug': [67, 71, 75],   # G增和弦: G4, B4, D#5
    'Aaug': [69, 73, 77],   # A增和弦: A4, C#5, F5
    'Baug': [71, 75, 79],   # B增和弦: B4, D#5, G5

    # 减和弦
    'Cdim': [60, 63, 66],   # C减和弦: C4, Eb4, F#4
    'Ddim': [62, 65, 68],   # D减和弦: D4, F4, Ab4
    'Edim': [64, 67, 70],   # E减和弦: E4, G4, A#4
    'Fdim': [65, 68, 71],   # F减和弦: F4, Ab4, B4
    'Gdim': [67, 70, 73],   # G减和弦: G4, Bb4, Db5
    'Adim': [69, 72, 75],   # A减和弦: A4, C5, D#5
    'Bdim': [71, 74, 77],   # B减和弦: B4, D5, F5

    # 悬挂和弦
    'Csus2': [60, 62, 67],  # C悬挂二和弦: C4, D4, G4
    'Csus4': [60, 65, 67],  # C悬挂四和弦: C4, F4, G4
    'Dsus2': [62, 64, 69],  # D悬挂二和弦: D4, E4, A4
    'Dsus4': [62, 67, 69],  # D悬挂四和弦: D4, G4, A4
    'Esus2': [64, 66, 71],  # E悬挂二和弦: E4, F#4, B4
    'Esus4': [64, 69, 71],  # E悬挂四和弦: E4, A4, B4
    'Gsus2': [67, 69, 74],  # G悬挂二和弦: G4, A4, D5
    'Gsus4': [67, 72, 74],  # G悬挂四和弦: G4, C5, D5

    # 大调加九和弦
    'Cadd9': [60, 64, 67, 74],     # Cadd9和弦: C4, E4, G4, D5
    'Dadd9': [62, 66, 69, 76],     # Dadd9和弦: D4, F#4, A4, E5
    'Eadd9': [64, 68, 71, 78],     # Eadd9和弦: E4, G#4, B4, F#5
    'Fadd9': [65, 69, 72, 79],     # Fadd9和弦: F4, A4, C5, G5
    'Gadd9': [67, 71, 74, 81],     # Gadd9和弦: G4, B4, D5, A5
    'Aadd9': [69, 73, 76, 83],     # Aadd9和弦: A4, C#5, E5, B5
    'Badd9': [71, 75, 79, 86],     # Badd9和弦: B4, D#5, F#5, C#6

    # 小调加九和弦
    'Cmadd9': [60, 63, 67, 74],    # Cmadd9和弦: C4, Eb4, G4, D5
    'Dmadd9': [62, 65, 69, 76],    # Dmadd9和弦: D4, F4, A4, E5
    'Emadd9': [64, 67, 71, 78],    # Emadd9和弦: E4, G4, B4, F#5
    'Fmadd9': [65, 68, 72, 79],    # Fmadd9和弦: F4, Ab4, C5, G5
    'Gmadd9': [67, 70, 74, 81],    # Gmadd9和弦: G4, Bb4, D5, A5
    'Amadd9': [69, 72, 76, 83],    # Amadd9和弦: A4, C5, E5, B5
    'Bmadd9': [71, 74, 79, 86],    # Bmadd9和弦: B4, D5, F#5, C#6

    # 大调六和弦
    'C6': [60, 64, 67, 69],     # C6和弦: C4, E4, G4, A4
    'D6': [62, 66, 69, 71],     # D6和弦: D4, F#4, A4, B4
    'E6': [64, 68, 71, 73],     # E6和弦: E4, G#4, B4, C#5
    'F6': [65, 69, 72, 74],     # F6和弦: F4, A4, C5, D5
    'G6': [67, 71, 74, 76],     # G6和弦: G4, B4, D5, E5
    'A6': [69, 73, 76, 78],     # A6和弦: A4, C#5, E5, F#5
    'B6': [71, 75, 79, 81],     # B6和弦: B4, D#5, F#5, G#5

    # 小调六和弦
    'Cm6': [60, 63, 67, 69],    # Cm6和弦: C4, Eb4, G4, A4
    'Dm6': [62, 65, 69, 71],    # Dm6和弦: D4, F4, A4, B4
    'Em6': [64, 67, 71, 73],    # Em6和弦: E4, G4, B4, C#5
    'Fm6': [65, 68, 72, 74],    # Fm6和弦: F4, Ab4, C5, D5
    'Gm6': [67, 70, 74, 76],    # Gm6和弦: G4, Bb4, D5, E5
    'Am6': [69, 72, 76, 78],    # Am6和弦: A4, C5, E5, F#5
    'Bm6': [71, 74, 79, 81],    # Bm6和弦: B4, D5, F#5, G#5

    # 属九和弦
    'C9': [60, 64, 67, 70, 74],     # C9和弦: C4, E4, G4, Bb4, D5
    'D9': [62, 66, 69, 72, 76],     # D9和弦: D4, F#4, A4, C5, E5
    'E9': [64, 68, 71, 74, 78],     # E9和弦: E4, G#4, B4, D5, F#5
    'F9': [65, 69, 72, 75, 79],     # F9和弦: F4, A4, C5, Eb5, G5
    'G9': [67, 71, 74, 77, 81],     # G9和弦: G4, B4, D5, F5, A5
    'A9': [69, 73, 76, 79, 83],     # A9和弦: A4, C#5, E5, G5, B5
    'B9': [71, 75, 79, 82, 86],     # B9和弦: B4, D#5, F#5, A5, C#6

    # 小大七和弦
    'Cm(maj7)': [60, 63, 67, 71],    # Cm(maj7)和弦: C4, Eb4, G4, B4
    'Dm(maj7)': [62, 65, 69, 73],    # Dm(maj7)和弦: D4, F4, A4, C#5
    'Em(maj7)': [64, 67, 71, 75],    # Em(maj7)和弦: E4, G4, B4, D#5
    'Fm(maj7)': [65, 68, 72, 76],    # Fm(maj7)和弦: F4, Ab4, C5, E5
    'Gm(maj7)': [67, 70, 74, 78],    # Gm(maj7)和弦: G4, Bb4, D5, F#5
    'Am(maj7)': [69, 72, 76, 80],    # Am(maj7)和弦: A4, C5, E5, G#5
    'Bm(maj7)': [71, 74, 79, 83],    # Bm(maj7)和弦: B4, D5, F#5, A#5

    # 增七和弦
    'Caug7': [60, 64, 68, 70],     # Caug7和弦: C4, E4, G#4, Bb4
    'Daug7': [62, 66, 70, 72],     # Daug7和弦: D4, F#4, A#4, C5
    'Eaug7': [64, 68, 72, 74],     # Eaug7和弦: E4, G#4, C5, D5
    'Faug7': [65, 69, 73, 75],     # Faug7和弦: F4, A4, C#5, Eb5
    'Gaug7': [67, 71, 75, 77],     # Gaug7和弦: G4, B4, D#5, F5
    'Aaug7': [69, 73, 77, 79],     # Aaug7和弦: A4, C#5, F5, G5
    'Baug7': [71, 75, 79, 81],     # Baug7和弦: B4, D#5, G5, A5

    # 挂留二和弦
    'Csus2': [60, 62, 67],     # Csus2和弦: C4, D4, G4
    'Dsus2': [62, 64, 69],     # Dsus2和弦: D4, E4, A4
    'Esus2': [64, 66, 71],     # Esus2和弦: E4, F#4, B4
    'Fsus2': [65, 67, 72],     # Fsus2和弦: F4, G4, C5
    'Gsus2': [67, 69, 74],     # Gsus2和弦: G4, A4, D5
    'Asus2': [69, 71, 76],     # Asus2和弦: A4, B4, E5
    'Bsus2': [71, 73, 79],     # Bsus2和弦: B4, C#5, F#5

    # 挂留四和弦
    'Csus4': [60, 65, 67],     # Csus4和弦: C4, F4, G4
    'Dsus4': [62, 67, 69],     # Dsus4和弦: D4, G4, A4
    'Esus4': [64, 69, 71],     # Esus4和弦: E4, A4, B4
    'Fsus4': [65, 70, 72],     # Fsus4和弦: F4, Bb4, C5
    'Gsus4': [67, 72, 74],     # Gsus4和弦: G4, C5, D5
    'Asus4': [69, 74, 76],     # Asus4和弦: A4, D5, E5
    'Bsus4': [71, 76, 79],     # Bsus4和弦: B4, E5, F#5

    # 属十一和弦
    'C11': [60, 64, 67, 70, 74, 77],     # C11和弦: C4, E4, G4, Bb4, D5, F5
    'D11': [62, 66, 69, 72, 76, 79],     # D11和弦: D4, F#4, A4, C5, E5, G5
    'E11': [64, 68, 71, 74, 78, 81],     # E11和弦: E4, G#4, B4, D5, F#5, A5
    'F11': [65, 69, 72, 75, 79, 82],     # F11和弦: F4, A4, C5, Eb5, G5, Bb5
    'G11': [67, 71, 74, 77, 81, 84],     # G11和弦: G4, B4, D5, F5, A5, C6
    'A11': [69, 73, 76, 79, 83, 86],     # A11和弦: A4, C#5, E5, G5, B5, D6
    'B11': [71, 75, 79, 82, 86, 89],     # B11和弦: B4, D#5, F#5, A5, C#6, E6

    # 属十三和弦
    'C13': [60, 64, 67, 70, 74, 77, 81],     # C13和弦: C4, E4, G4, Bb4, D5, F5, A5
    'D13': [62, 66, 69, 72, 76, 79, 83],     # D13和弦: D4, F#4, A4, C5, E5, G5, B5
    'E13': [64, 68, 71, 74, 78, 81, 85],     # E13和弦: E4, G#4, B4, D5, F#5, A5, C#6
    'F13': [65, 69, 72, 75, 79, 82, 86],     # F13和弦: F4, A4, C5, Eb5, G5, Bb5, D6
    'G13': [67, 71, 74, 77, 81, 84, 88],     # G13和弦: G4, B4, D5, F5, A5, C6, E6
    'A13': [69, 73, 76, 79, 83, 86, 90],     # A13和弦: A4, C#5, E5, G5, B5, D6, F#6
    'B13': [71, 75, 79, 82, 86, 89, 93],     # B13和弦: B4, D#5, F#5, A5, C#6, E6, G#6

    # 小十一和弦
    'Cm11': [60, 63, 67, 70, 74, 77],     # Cm11和弦: C4, Eb4, G4, Bb4, D5, F5
    'Dm11': [62, 65, 69, 72, 76, 79],     # Dm11和弦: D4, F4, A4, C5, E5, G5
    'Em11': [64, 67, 71, 74, 78, 81],     # Em11和弦: E4, G4, B4, D5, F#5, A5
    'Fm11': [65, 68, 72, 75, 79, 82],     # Fm11和弦: F4, Ab4, C5, Eb5, G5, Bb5
    'Gm11': [67, 70, 74, 77, 81, 84],     # Gm11和弦: G4, Bb4, D5, F5, A5, C6
    'Am11': [69, 72, 76, 79, 83, 86],     # Am11和弦: A4, C5, E5, G5, B5, D6
    'Bm11': [71, 74, 79, 82, 86, 89],     # Bm11和弦: B4, D5, F#5, A5, C#6, E6

    # 小十三和弦
    'Cm13': [60, 63, 67, 70, 74, 77, 81],     # Cm13和弦: C4, Eb4, G4, Bb4, D5, F5, A5
    'Dm13': [62, 65, 69, 72, 76, 79, 83],     # Dm13和弦: D4, F4, A4, C5, E5, G5, B5
    'Em13': [64, 67, 71, 74, 78, 81, 85],     # Em13和弦: E4, G4, B4, D5, F#5, A5, C#6
    'Fm13': [65, 68, 72, 75, 79, 82, 86],     # Fm13和弦: F4, Ab4, C5, Eb5, G5, Bb5, D6
    'Gm13': [67, 70, 74, 77, 81, 84, 88],     # Gm13和弦: G4, Bb4, D5, F5, A5, C6, E6
    'Am13': [69, 72, 76, 79, 83, 86, 90],     # Am13和弦: A4, C5, E5, G5, B5, D6, F#6
    'Bm13': [71, 74, 79, 82, 86, 89, 93],     # Bm13和弦: B4, D5, F#5, A5, C#6, E6, G#6

    # 增九和弦
    'Caug9': [60, 64, 68, 70, 74],     # Caug9和弦: C4, E4, G#4, Bb4, D5
    'Daug9': [62, 66, 70, 72, 76],     # Daug9和弦: D4, F#4, A#4, C5, E5
    'Eaug9': [64, 68, 72, 74, 78],     # Eaug9和弦: E4, G#4, C5, D5, F#5
    'Faug9': [65, 69, 73, 75, 79],     # Faug9和弦: F4, A4, C#5, Eb5, G5
    'Gaug9': [67, 71, 75, 77, 81],     # Gaug9和弦: G4, B4, D#5, F5, A5
    'Aaug9': [69, 73, 77, 79, 83],     # Aaug9和弦: A4, C#5, F5, G5, B5
    'Baug9': [71, 75, 79, 81, 85],     # Baug9和弦: B4, D#5, G5, A5, C#6

    # 减七和弦
    'Cdim7': [60, 63, 66, 69],     # Cdim7和弦: C4, Eb4, F#4, A4
    'Ddim7': [62, 65, 68, 71],     # Ddim7和弦: D4, F4, Ab4, B4
    'Edim7': [64, 67, 70, 73],     # Edim7和弦: E4, G4, A#4, C#5
    'Fdim7': [65, 68, 71, 74],     # Fdim7和弦: F4, Ab4, B4, D5
    'Gdim7': [67, 70, 73, 76],     # Gdim7和弦: G4, Bb4, Db5, E5
    'Adim7': [69, 72, 75, 78],     # Adim7和弦: A4, C5, D#5, F#5
    'Bdim7': [71, 74, 77, 80],     # Bdim7和弦: B4, D5, F5, G#5

    # 挂留九和弦
    'Csus9': [60, 65, 67, 74],     # Csus9和弦: C4, F4, G4, D5
    'Dsus9': [62, 67, 69, 76],     # Dsus9和弦: D4, G4, A4, E5
    'Esus9': [64, 69, 71, 78],     # Esus9和弦: E4, A4, B4, F#5
    'Fsus9': [65, 70, 72, 79],     # Fsus9和弦: F4, Bb4, C5, G5
    'Gsus9': [67, 72, 74, 81],     # Gsus9和弦: G4, C5, D5, A5
    'Asus9': [69, 74, 76, 83],     # Asus9和弦: A4, D5, E5, B5
    'Bsus9': [71, 76, 79, 86],     # Bsus9和弦: B4, E5, F#5, C#6

    # 挂留十三和弦
    'Csus13': [60, 65, 67, 74, 77],     # Csus13和弦: C4, F4, G4, D5, F5
    'Dsus13': [62, 67, 69, 76, 79],     # Dsus13和弦: D4, G4, A4, E5, G5
    'Esus13': [64, 69, 71, 78, 81],     # Esus13和弦: E4, A4, B4, F#5, A5
    'Fsus13': [65, 70, 72, 79, 82],     # Fsus13和弦: F4, Bb4, C5, G5, Bb5
    'Gsus13': [67, 72, 74, 81, 84],     # Gsus13和弦: G4, C5, D5, A5, C6
    'Asus13': [69, 74, 76, 83, 86],     # Asus13和弦: A4, D5, E5, B5, D6
    'Bsus13': [71, 76, 79, 86, 89],     # Bsus13和弦: B4, E5, F#5, C#6, E6

    # 大调七和弦
    'Cmaj7': [60, 64, 67, 71],  # C大七和弦: C4, E4, G4, B4
    'Dmaj7': [62, 66, 69, 73],  # D大七和弦: D4, F#4, A4, C#5
    'Emaj7': [64, 68, 71, 75],  # E大七和弦: E4, G#4, B4, D#5
    'Fmaj7': [65, 69, 72, 76],  # F大七和弦: F4, A4, C5, E5
    'Gmaj7': [67, 71, 74, 78],  # G大七和弦: G4, B4, D5, F#5
    'Amaj7': [69, 73, 76, 80],  # A大七和弦: A4, C#5, E5, G#5
    'Bmaj7': [71, 75, 79, 83],  # B大七和弦: B4, D#5, F#5, A#5

    # 小调七和弦
    'Cm7': [60, 63, 67, 70],   # C小七和弦: C4, Eb4, G4, Bb4
    'Dm7': [62, 65, 69, 72],   # D小七和弦: D4, F4, A4, C5
    'Em7': [64, 67, 71, 74],   # E小七和弦: E4, G4, B4, D5
    'Fm7': [65, 68, 72, 75],   # F小七和弦: F4, Ab4, C5, Eb5
    'Gm7': [67, 70, 74, 77],   # G小七和弦: G4, Bb4, D5, F5
    'Am7': [69, 72, 76, 79],   # A小七和弦: A4, C5, E5, G5
    'Bm7': [71, 74, 79, 82],   # B小七和弦: B4, D5, F#5, A5

    # 属七和弦
    'C7': [60, 64, 67, 70],    # C7和弦: C4, E4, G4, Bb4
    'D7': [62, 66, 69, 72],    # D7和弦: D4, F#4, A4, C5
    'E7': [64, 68, 71, 74],    # E7和弦: E4, G#4, B4, D5
    'F7': [65, 69, 72, 75],    # F7和弦: F4, A4, C5, Eb5
    'G7': [67, 71, 74, 77],    # G7和弦: G4, B4, D5, F5
    'A7': [69, 73, 76, 79],    # A7和弦: A4, C#5, E5, G5
    'B7': [71, 75, 79, 82],    # B7和弦: B4, D#5, F#5, A5

    # 大九和弦
    'Cmaj9': [60, 64, 67, 71, 74],   # C大九和弦: C4, E4, G4, B4, D5
    'Dmaj9': [62, 66, 69, 73, 76],   # D大九和弦: D4, F#4, A4, C#5, E5
    'Emaj9': [64, 68, 71, 75, 78],   # E大九和弦: E4, G#4, B4, D#5, F#5
    'Fmaj9': [65, 69, 72, 76, 79],   # F大九和弦: F4, A4, C5, E5, G5
    'Gmaj9': [67, 71, 74, 78, 81],   # G大九和弦: G4, B4, D5, F#5, A5
    'Amaj9': [69, 73, 76, 80, 83],   # A大九和弦: A4, C#5, E5, G#5, B5
    'Bmaj9': [71, 75, 79, 83, 86],   # B大九和弦: B4, D#5, F#5, A#5, C#6

    # 小九和弦
    'Cm9': [60, 63, 67, 70, 74],   # C小九和弦: C4, Eb4, G4, Bb4, D5
    'Dm9': [62, 65, 69, 72, 75],   # D小九和弦: D4, F4, A4, C5, E5
    'Em9': [64, 67, 71, 74, 78],   # E小九和弦: E4, G4, B4, D5, F#5
    'Fm9': [65, 68, 72, 75, 79],   # F小九和弦: F4, Ab4, C5, Eb5, G5
    'Gm9': [67, 70, 74, 77, 81],   # G小九和弦: G4, Bb4, D5, F5, A5
    'Am9': [69, 72, 76, 79, 83],   # A小九和弦: A4, C5, E5, G5, B5
    'Bm9': [71, 74, 79, 82, 86],   # B小九和弦: B4, D5, F#5, A5, C#6

    # 增和弦
    'Caug': [60, 64, 68],   # C增和弦: C4, E4, G#4
    'Daug': [62, 66, 70],   # D增和弦: D4, F#4, A#4
    'Eaug': [64, 68, 72],   # E增和弦: E4, G#4, C5
    'Faug': [65, 69, 73],   # F增和弦: F4, A4, C#5
    'Gaug': [67, 71, 75],   # G增和弦: G4, B4, D#5
    'Aaug': [69, 73, 77],   # A增和弦: A4, C#5, F5
    'Baug': [71, 75, 79],   # B增和弦: B4, D#5, G5

    # 减和弦
    'Cdim': [60, 63, 66],   # C减和弦: C4, Eb4, F#4
    'Ddim': [62, 65, 68],   # D减和弦: D4, F4, Ab4
    'Edim': [64, 67, 70],   # E减和弦: E4, G4, A#4
    'Fdim': [65, 68, 71],   # F减和弦: F4, Ab4, B4
    'Gdim': [67, 70, 73],   # G减和弦: G4, Bb4, Db5
    'Adim': [69, 72, 75],   # A减和弦: A4, C5, D#5
    'Bdim': [71, 74, 77],   # B减和弦: B4, D5, F5

    # 悬挂和弦
    'Csus2': [60, 62, 67],  # C悬挂二和弦: C4, D4, G4
    'Csus4': [60, 65, 67],  # C悬挂四和弦: C4, F4, G4
    'Dsus2': [62, 64, 69],  # D悬挂二和弦: D4, E4, A4
    'Dsus4': [62, 67, 69],  # D悬挂四和弦: D4, G4, A4
    'Esus2': [64, 66, 71],  # E悬挂二和弦: E4, F#4, B4
    'Esus4': [64, 69, 71],  # E悬挂四和弦: E4, A4, B4
    'Gsus2': [67, 69, 74],  # G悬挂二和弦: G4, A4, D5
    'Gsus4': [67, 72, 74],  # G悬挂四和弦: G4, C5, D5

    # 大调add9和弦
    'Cadd9': [60, 64, 67, 74],     # Cadd9和弦: C4, E4, G4, D5
    'Dadd9': [62, 66, 69, 76],     # Dadd9和弦: D4, F#4, A4, E5
    'Eadd9': [64, 68, 71, 78],     # Eadd9和弦: E4, G#4, B4, F#5
    'Fadd9': [65, 69, 72, 79],     # Fadd9和弦: F4, A4, C5, G5
    'Gadd9': [67, 71, 74, 81],     # Gadd9和弦: G4, B4, D5, A5
    'Aadd9': [69, 73, 76, 83],     # Aadd9和弦: A4, C#5, E5, B5
    'Badd9': [71, 75, 79, 86],     # Badd9和弦: B4, D#5, F#5, C#6

    # 小调add9和弦
    'Cmadd9': [60, 63, 67, 74],    # Cmadd9和弦: C4, Eb4, G4, D5
    'Dmadd9': [62, 65, 69, 76],    # Dmadd9和弦: D4, F4, A4, E5
    'Emadd9': [64, 67, 71, 78],    # Emadd9和弦: E4, G4, B4, F#5
    'Fmadd9': [65, 68, 72, 79],    # Fmadd9和弦: F4, Ab4, C5, G5
    'Gmadd9': [67, 70, 74, 81],    # Gmadd9和弦: G4, Bb4, D5, A5
    'Amadd9': [69, 72, 76, 83],    # Amadd9和弦: A4, C5, E5, B5
    'Bmadd9': [71, 74, 79, 86],    # Bmadd9和弦: B4, D5, F#5, C#6

    # 大调六和弦
    'C6': [60, 64, 67, 69],     # C6和弦: C4, E4, G4, A4
    'D6': [62, 66, 69, 71],     # D6和弦: D4, F#4, A4, B4
    'E6': [64, 68, 71, 73],     # E6和弦: E4, G#4, B4, C#5
    'F6': [65, 69, 72, 74],     # F6和弦: F4, A4, C5, D5
    'G6': [67, 71, 74, 76],     # G6和弦: G4, B4, D5, E5
    'A6': [69, 73, 76, 78],     # A6和弦: A4, C#5, E5, F#5
    'B6': [71, 75, 79, 81],     # B6和弦: B4, D#5, F#5, G#5

    # 小调六和弦
    'Cm6': [60, 63, 67, 69],    # Cm6和弦: C4, Eb4, G4, A4
    'Dm6': [62, 65, 69, 71],    # Dm6和弦: D4, F4, A4, B4
    'Em6': [64, 67, 71, 73],    # Em6和弦: E4, G4, B4, C#5
    'Fm6': [65, 68, 72, 74],    # Fm6和弦: F4, Ab4, C5, D5
    'Gm6': [67, 70, 74, 76],    # Gm6和弦: G4, Bb4, D5, E5
    'Am6': [69, 72, 76, 78],    # Am6和弦: A4, C5, E5, F#5
    'Bm6': [71, 74, 79, 81],    # Bm6和弦: B4, D5, F#5, G#5

    # 属九和弦
    'C9': [60, 64, 67, 70, 74],     # C9和弦: C4, E4, G4, Bb4, D5
    'D9': [62, 66, 69, 72, 76],     # D9和弦: D4, F#4, A4, C5, E5
    'E9': [64, 68, 71, 74, 78],     # E9和弦: E4, G#4, B4, D5, F#5
    'F9': [65, 69, 72, 75, 79],     # F9和弦: F4, A4, C5, Eb5, G5
    'G9': [67, 71, 74, 77, 81],     # G9和弦: G4, B4, D5, F5, A5
    'A9': [69, 73, 76, 79, 83],     # A9和弦: A4, C#5, E5, G5, B5
    'B9': [71, 75, 79, 82, 86],     # B9和弦: B4, D#5, F#5, A5, C#6

    # 小大七和弦
    'Cm(maj7)': [60, 63, 67, 71],    # Cm(maj7)和弦: C4, Eb4, G4, B4
    'Dm(maj7)': [62, 65, 69, 73],    # Dm(maj7)和弦: D4, F4, A4, C#5
    'Em(maj7)': [64, 67, 71, 75],    # Em(maj7)和弦: E4, G4, B4, D#5
    'Fm(maj7)': [65, 68, 72, 76],    # Fm(maj7)和弦: F4, Ab4, C5, E5
    'Gm(maj7)': [67, 70, 74, 78],    # Gm(maj7)和弦: G4, Bb4, D5, F#5
    'Am(maj7)': [69, 72, 76, 80],    # Am(maj7)和弦: A4, C5, E5, G#5
    'Bm(maj7)': [71, 74, 79, 83],    # Bm(maj7)和弦: B4, D5, F#5, A#5

    # 增七和弦
    'Caug7': [60, 64, 68, 70],     # Caug7和弦: C4, E4, G#4, Bb4
    'Daug7': [62, 66, 70, 72],     # Daug7和弦: D4, F#4, A#4, C5
    'Eaug7': [64, 68, 72, 74],     # Eaug7和弦: E4, G#4, C5, D5
    'Faug7': [65, 69, 73, 75],     # Faug7和弦: F4, A4, C#5, Eb5
    'Gaug7': [67, 71, 75, 77],     # Gaug7和弦: G4, B4, D#5, F5
    'Aaug7': [69, 73, 77, 79],     # Aaug7和弦: A4, C#5, F5, G5
    'Baug7': [71, 75, 79, 81],     # Baug7和弦: B4, D#5, G5, A5

    # 挂留二和弦
    'Csus2': [60, 62, 67],     # Csus2和弦: C4, D4, G4
    'Dsus2': [62, 64, 69],     # Dsus2和弦: D4, E4, A4
    'Esus2': [64, 66, 71],     # Esus2和弦: E4, F#4, B4
    'Fsus2': [65, 67, 72],     # Fsus2和弦: F4, G4, C5
    'Gsus2': [67, 69, 74],     # Gsus2和弦: G4, A4, D5
    'Asus2': [69, 71, 76],     # Asus2和弦: A4, B4, E5
    'Bsus2': [71, 73, 79],     # Bsus2和弦: B4, C#5, F#5

    # 挂留四和弦
    'Csus4': [60, 65, 67],     # Csus4和弦: C4, F4, G4
    'Dsus4': [62, 67, 69],     # Dsus4和弦: D4, G4, A4
    'Esus4': [64, 69, 71],     # Esus4和弦: E4, A4, B4
    'Fsus4': [65, 70, 72],     # Fsus4和弦: F4, Bb4, C5
    'Gsus4': [67, 72, 74],     # Gsus4和弦: G4, C5, D5
    'Asus4': [69, 74, 76],     # Asus4和弦: A4, D5, E5
    'Bsus4': [71, 76, 79],     # Bsus4和弦: B4, E5, F#5

    # 属十一和弦
    'C11': [60, 64, 67, 70, 74, 77],     # C11和弦: C4, E4, G4, Bb4, D5, F5
    'D11': [62, 66, 69, 72, 76, 79],     # D11和弦: D4, F#4, A4, C5, E5, G5
    'E11': [64, 68, 71, 74, 78, 81],     # E11和弦: E4, G#4, B4, D5, F#5, A5
    'F11': [65, 69, 72, 75, 79, 82],     # F11和弦: F4, A4, C5, Eb5, G5, Bb5
    'G11': [67, 71, 74, 77, 81, 84],     # G11和弦: G4, B4, D5, F5, A5, C6
    'A11': [69, 73, 76, 79, 83, 86],     # A11和弦: A4, C#5, E5, G5, B5, D6
    'B11': [71, 75, 79, 82, 86, 89],     # B11和弦: B4, D#5, F#5, A5, C#6, E6

    # 属十三和弦
    'C13': [60, 64, 67, 70, 74, 77, 81],     # C13和弦: C4, E4, G4, Bb4, D5, F5, A5
    'D13': [62, 66, 69, 72, 76, 79, 83],     # D13和弦: D4, F#4, A4, C5, E5, G5, B5
    'E13': [64, 68, 71, 74, 78, 81, 85],     # E13和弦: E4, G#4, B4, D5, F#5, A5, C#6
    'F13': [65, 69, 72, 75, 79, 82, 86],     # F13和弦: F4, A4, C5, Eb5, G5, Bb5, D6
    'G13': [67, 71, 74, 77, 81, 84, 88],     # G13和弦: G4, B4, D5, F5, A5, C6, E6
    'A13': [69, 73, 76, 79, 83, 86, 90],     # A13和弦: A4, C#5, E5, G5, B5, D6, F#6
    'B13': [71, 75, 79, 82, 86, 89, 93],     # B13和弦: B4, D#5, F#5, A5, C#6, E6, G#6

    # 小十一和弦
    'Cm11': [60, 63, 67, 70, 74, 77],     # Cm11和弦: C4, Eb4, G4, Bb4, D5, F5
    'Dm11': [62, 65, 69, 72, 76, 79],     # Dm11和弦: D4, F4, A4, C5, E5, G5
    'Em11': [64, 67, 71, 74, 78, 81],     # Em11和弦: E4, G4, B4, D5, F#5, A5
    'Fm11': [65, 68, 72, 75, 79, 82],     # Fm11和弦: F4, Ab4, C5, Eb5, G5, Bb5
    'Gm11': [67, 70, 74, 77, 81, 84],     # Gm11和弦: G4, Bb4, D5, F5, A5, C6
    'Am11': [69, 72, 76, 79, 83, 86],     # Am11和弦: A4, C5, E5, G5, B5, D6
    'Bm11': [71, 74, 79, 82, 86, 89],     # Bm11和弦: B4, D5, F#5, A5, C#6, E6

    # 小十三和弦
    'Cm13': [60, 63, 67, 70, 74, 77, 81],     # Cm13和弦: C4, Eb4, G4, Bb4, D5, F5, A5
    'Dm13': [62, 65, 69, 72, 76, 79, 83],     # Dm13和弦: D4, F4, A4, C5, E5, G5, B5
    'Em13': [64, 67, 71, 74, 78, 81, 85],     # Em13和弦: E4, G4, B4, D5, F#5, A5, C#6
    'Fm13': [65, 68, 72, 75, 79, 82, 86],     # Fm13和弦: F4, Ab4, C5, Eb5, G5, Bb5, D6
    'Gm13': [67, 70, 74, 77, 81, 84, 88],     # Gm13和弦: G4, Bb4, D5, F5, A5, C6, E6
    'Am13': [69, 72, 76, 79, 83, 86, 90],     # Am13和弦: A4, C5, E5, G5, B5, D6, F#6
    'Bm13': [71, 74, 79, 82, 86, 89, 93],     # Bm13和弦: B4, D5, F#5, A5, C#6, E6, G#6

    # 增九和弦
    'Caug9': [60, 64, 68, 70, 74],     # Caug9和弦: C4, E4, G#4, Bb4, D5
    'Daug9': [62, 66, 70, 72, 76],     # Daug9和弦: D4, F#4, A#4, C5, E5
    'Eaug9': [64, 68, 72, 74, 78],     # Eaug9和弦: E4, G#4, C5, D5, F#5
    'Faug9': [65, 69, 73, 75, 79],     # Faug9和弦: F4, A4, C#5, Eb5, G5
    'Gaug9': [67, 71, 75, 77, 81],     # Gaug9和弦: G4, B4, D#5, F5, A5
    'Aaug9': [69, 73, 77, 79, 83],     # Aaug9和弦: A4, C#5, F5, G5, B5
    'Baug9': [71, 75, 79, 81, 85],     # Baug9和弦: B4, D#5, G5, A5, C#6

    # 减七和弦
    'Cdim7': [60, 63, 66, 69],     # Cdim7和弦: C4, Eb4, F#4, A4
    'Ddim7': [62, 65, 68, 71],     # Ddim7和弦: D4, F4, Ab4, B4
    'Edim7': [64, 67, 70, 73],     # Edim7和弦: E4, G4, A#4, C#5
    'Fdim7': [65, 68, 71, 74],     # Fdim7和弦: F4, Ab4, B4, D5
    'Gdim7': [67, 70, 73, 76],     # Gdim7和弦: G4, Bb4, Db5, E5
    'Adim7': [69, 72, 75, 78],     # Adim7和弦: A4, C5, D#5, F#5
    'Bdim7': [71, 74, 77, 80],     # Bdim7和弦: B4, D5, F5, G#5

    # 挂留九和弦
    'Csus9': [60, 65, 67, 74],     # Csus9和弦: C4, F4, G4, D5
    'Dsus9': [62, 67, 69, 76],     # Dsus9和弦: D4, G4, A4, E5
    'Esus9': [64, 69, 71, 78],     # Esus9和弦: E4, A4, B4, F#5
    'Fsus9': [65, 70, 72, 79],     # Fsus9和弦: F4, Bb4, C5, G5
    'Gsus9': [67, 72, 74, 81],     # Gsus9和弦: G4, C5, D5, A5
    'Asus9': [69, 74, 76, 83],     # Asus9和弦: A4, D5, E5, B5
    'Bsus9': [71, 76, 79, 86],     # Bsus9和弦: B4, E5, F#5, C#6

    # 挂留十三和弦
    'Csus13': [60, 65, 67, 74, 77],     # Csus13和弦: C4, F4, G4, D5, F5
    'Dsus13': [62, 67, 69, 76, 79],     # Dsus13和弦: D4, G4, A4, E5, G5
    'Esus13': [64, 69, 71, 78, 81],     # Esus13和弦: E4, A4, B4, F#5, A5
    'Fsus13': [65, 70, 72, 79, 82],     # Fsus13和弦: F4, Bb4, C5, G5, Bb5
    'Gsus13': [67, 72, 74, 81, 84],     # Gsus13和弦: G4, C5, D5, A5, C6
    'Asus13': [69, 74, 76, 83, 86],     # Asus13和弦: A4, D5, E5, B5, D6
    'Bsus13': [71, 76, 79, 86, 89],     # Bsus13和弦: B4, E5, F#5, C#6, E6

    # 大调七降五和弦
    'Cmaj7b5': [60, 64, 66, 71],  # C大七降五和弦: C4, E4, Gb4, B4
    'Dmaj7b5': [62, 66, 68, 73],  # D大七降五和弦: D4, F#4, Ab4, C#5
    'Emaj7b5': [64, 68, 70, 75],  # E大七降五和弦: E4, G#4, Bb4, D#5
    'Fmaj7b5': [65, 69, 71, 76],  # F大七降五和弦: F4, A4, Cb5, E5
    'Gmaj7b5': [67, 71, 73, 78],  # G大七降五和弦: G4, B4, Db5, F#5
    'Amaj7b5': [69, 73, 75, 80],  # A大七降五和弦: A4, C#5, Eb5, G#5
    'Bmaj7b5': [71, 75, 77, 82],  # B大七降五和弦: B4, D#5, F5, A#5

    # 小调七降五和弦
    'Cm7b5': [60, 63, 66, 70],   # C小七降五和弦: C4, Eb4, Gb4, Bb4
    'Dm7b5': [62, 65, 68, 72],   # D小七降五和弦: D4, F4, Ab4, C5
    'Em7b5': [64, 67, 70, 74],   # E小七降五和弦: E4, G4, Bb4, D5
    'Fm7b5': [65, 68, 71, 75],   # F小七降五和弦: F4, Ab4, Cb5, Eb5
    'Gm7b5': [67, 70, 73, 77],   # G小七降五和弦: G4, Bb4, Db5, F5
    'Am7b5': [69, 72, 75, 79],   # A小七降五和弦: A4, C5, Eb5, G5
    'Bm7b5': [71, 74, 77, 81],   # B小七降五和弦: B4, D5, F5, A5

    # 属七升五和弦
    'C7#5': [60, 64, 68, 70],    # C7升五和弦: C4, E4, G#4, Bb4
    'D7#5': [62, 66, 70, 72],    # D7升五和弦: D4, F#4, A#4, C5
    'E7#5': [64, 68, 72, 74],    # E7升五和弦: E4, G#4, C5, D5
    'F7#5': [65, 69, 73, 75],    # F7升五和弦: F4, A4, C#5, Eb5
    'G7#5': [67, 71, 75, 77],    # G7升五和弦: G4, B4, D#5, F5
    'A7#5': [69, 73, 77, 79],    # A7升五和弦: A4, C#5, F5, G5
    'B7#5': [71, 75, 79, 81],    # B7升五和弦: B4, D#5, G5, A5

    # 属七降九和弦
    'C7b9': [60, 64, 67, 70, 73],     # C7降九和弦: C4, E4, G4, Bb4, Db5
    'D7b9': [62, 66, 69, 72, 75],     # D7降九和弦: D4, F#4, A4, C5, Eb5
    'E7b9': [64, 68, 71, 74, 77],     # E7降九和弦: E4, G#4, B4, D5, F5
    'F7b9': [65, 69, 72, 75, 78],     # F7降九和弦: F4, A4, C5, Eb5, Gb5
    'G7b9': [67, 71, 74, 77, 80],     # G7降九和弦: G4, B4, D5, F5, Ab5
    'A7b9': [69, 73, 76, 79, 82],     # A7降九和弦: A4, C#5, E5, G5, Bb5
    'B7b9': [71, 75, 79, 82, 85],     # B7降九和弦: B4, D#5, F#5, A5, C6

    # 属七升九和弦
    'C7#9': [60, 64, 67, 70, 75],     # C7升九和弦: C4, E4, G4, Bb4, D#5
    'D7#9': [62, 66, 69, 72, 77],     # D7升九和弦: D4, F#4, A4, C5, F5
    'E7#9': [64, 68, 71, 74, 79],     # E7升九和弦: E4, G#4, B4, D5, G5
    'F7#9': [65, 69, 72, 75, 80],     # F7升九和弦: F4, A4, C5, Eb5, G#5
    'G7#9': [67, 71, 74, 77, 82],     # G7升九和弦: G4, B4, D5, F5, A#5
    'A7#9': [69, 73, 76, 79, 84],     # A7升九和弦: A4, C#5, E5, G5, C6
    'B7#9': [71, 75, 79, 82, 87],     # B7升九和弦: B4, D#5, F#5, A5, D6

    # 大调七升十一和弦
    'Cmaj7#11': [60, 64, 67, 71, 78],   # C大七升十一和弦: C4, E4, G4, B4, F#5
    'Dmaj7#11': [62, 66, 69, 73, 80],   # D大七升十一和弦: D4, F#4, A4, C#5, G#5
    'Emaj7#11': [64, 68, 71, 75, 82],   # E大七升十一和弦: E4, G#4, B4, D#5, A#5
    'Fmaj7#11': [65, 69, 72, 76, 83],   # F大七升十一和弦: F4, A4, C5, E5, B5
    'Gmaj7#11': [67, 71, 74, 78, 85],   # G大七升十一和弦: G4, B4, D5, F#5, C#6
    'Amaj7#11': [69, 73, 76, 80, 87],   # A大七升十一和弦: A4, C#5, E5, G#5, D6
    'Bmaj7#11': [71, 75, 79, 83, 89],   # B大七升十一和弦: B4, D#5, F#5, A#5, E6

    # 小调七升十一和弦
    'Cm7#11': [60, 63, 67, 70, 78],   # C小七升十一和弦: C4, Eb4, G4, Bb4, F#5
    'Dm7#11': [62, 65, 69, 72, 80],   # D小七升十一和弦: D4, F4, A4, C5, G#5
    'Em7#11': [64, 67, 71, 74, 82],   # E小七升十一和弦: E4, G4, B4, D5, A#5
    'Fm7#11': [65, 68, 72, 75, 83],   # F小七升十一和弦: F4, Ab4, C5, Eb5, B5
    'Gm7#11': [67, 70, 74, 77, 85],   # G小七升十一和弦: G4, Bb4, D5, F5, C#6
    'Am7#11': [69, 72, 76, 79, 87],   # A小七升十一和弦: A4, C5, E5, G5, D6
    'Bm7#11': [71, 74, 79, 82, 89],   # B小七升十一和弦: B4, D5, F#5, A5, E6

    # 属七降十三和弦
    'C7b13': [60, 64, 67, 70, 74, 77, 80],     # C7降十三和弦: C4, E4, G4, Bb4, D5, F5, Ab5
    'D7b13': [62, 66, 69, 72, 76, 79, 82],     # D7降十三和弦: D4, F#4, A4, C5, E5, G5, Bb5
    'E7b13': [64, 68, 71, 74, 78, 81, 84],     # E7降十三和弦: E4, G#4, B4, D5, F#5, A5, C6
    'F7b13': [65, 69, 72, 75, 79, 82, 85],     # F7降十三和弦: F4, A4, C5, Eb5, G5, Bb5, Db6
    'G7b13': [67, 71, 74, 77, 81, 84, 87],     # G7降十三和弦: G4, B4, D5, F5, A5, C6, Eb6
    'A7b13': [69, 73, 76, 79, 83, 86, 89],     # A7降十三和弦: A4, C#5, E5, G5, B5, D6, F6
    'B7b13': [71, 75, 79, 82, 86, 89, 92],     # B7降十三和弦: B4, D#5, F#5, A5, C#6, E6, G6

    # 大调九升十一和弦
    'Cmaj9#11': [60, 64, 67, 71, 74, 78],   # C大九升十一和弦: C4, E4, G4, B4, D5, F#5
    'Dmaj9#11': [62, 66, 69, 73, 76, 80],   # D大九升十一和弦: D4, F#4, A4, C#5, E5, G#5
    'Emaj9#11': [64, 68, 71, 75, 78, 82],   # E大九升十一和弦: E4, G#4, B4, D#5, F#5, A#5
    'Fmaj9#11': [65, 69, 72, 76, 79, 83],   # F大九升十一和弦: F4, A4, C5, E5, G5, B5
    'Gmaj9#11': [67, 71, 74, 78, 81, 85],   # G大九升十一和弦: G4, B4, D5, F#5, A5, C#6
    'Amaj9#11': [69, 73, 76, 80, 83, 87],   # A大九升十一和弦: A4, C#5, E5, G#5, B5, D6
    'Bmaj9#11': [71, 75, 79, 83, 86, 89],   # B大九升十一和弦: B4, D#5, F#5, A#5, C#6, E6

    # 小调九升十一和弦
    'Cm9#11': [60, 63, 67, 70, 74, 78],   # C小九升十一和弦: C4, Eb4, G4, Bb4, D5, F#5
    'Dm9#11': [62, 65, 69, 72, 76, 80],   # D小九升十一和弦: D4, F4, A4, C5, E5, G#5
    'Em9#11': [64, 67, 71, 74, 78, 82],   # E小九升十一和弦: E4, G4, B4, D5, F#5, A#5
    'Fm9#11': [65, 68, 72, 75, 79, 83],   # F小九升十一和弦: F4, Ab4, C5, Eb5, G5, B5
    'Gm9#11': [67, 70, 74, 77, 81, 85],   # G小九升十一和弦: G4, Bb4, D5, F5, A5, C#6
    'Am9#11': [69, 72, 76, 79, 83, 87],   # A小九升十一和弦: A4, C5, E5, G5, B5, D6
    'Bm9#11': [71, 74, 79, 82, 86, 89],   # B小九升十一和弦: B4, D5, F#5, A5, C#6, E6
}

import sys
from mido import MidiFile, MidiTrack, Message, MetaMessage

chords = {
    'C': [60, 64, 67],
    'G': [67, 71, 74],
    'Am': [69, 72, 76],
    'Em': [64, 67, 71],
    'F': [65, 69, 72],
    'Dm': [62, 65, 69],
}

def read_bpm():
    try:
        bpm = float(sys.argv[1])
        return bpm
    except (IndexError, ValueError):
        return 120

def read_input():
    try:
        with open('input.txt', 'r') as file:
            chords_sequence = file.read().strip()
        return chords_sequence.split('\n')
    except Exception as e:
        print(f'读取错误: {e}')
        return []

def generate_midi(chords_sequence, bpm):
    try:
        midi = MidiFile()
        track = MidiTrack()
        midi.tracks.append(track)

        tempo = int(60000000 / bpm)
        track.append(MetaMessage('set_tempo', tempo=tempo))

        track.append(Message('program_change', program=0))
        track.name = 'chords'

        ticks_per_beat = midi.ticks_per_beat
        note_duration_ticks = int(ticks_per_beat)

        for chord_str in chords_sequence:
            chord_str = chord_str.strip()
            if not chord_str:
                track.append(Message('note_off', time=note_duration_ticks))
                continue

            chords_list = chord_str.split('-')
            for chord in chords_list:
                chord = chord.strip()

                if chord in chords:
                    for note in chords[chord]:
                        track.append(Message('note_on', note=note, velocity=64, time=0))
                    for note in chords[chord]:
                        track.append(Message('note_off', note=note, velocity=64, time=note_duration_ticks))

        midi.save('midi.mid')
    except Exception as e:
        print(f'生成错误: {e}')

def main():
    bpm = read_bpm()
    chords_sequence = read_input()
    if chords_sequence:
        generate_midi(chords_sequence, bpm)

if __name__ == '__main__':
    main()
